/*
 * Copyright (c) 2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "ohos_adapter/bridge/ark_ohos_image_decoder_adapter_impl.h"

#include "ohos_image_decoder_adapter.h"

namespace OHOS::ArkWeb {

ArkOhosImageDecoderAdapterImpl::ArkOhosImageDecoderAdapterImpl(std::shared_ptr<OHOS::NWeb::OhosImageDecoderAdapter> ref)
    : real_(ref)
{}

bool ArkOhosImageDecoderAdapterImpl::ParseImageInfo(const uint8_t* data, uint32_t size)
{
    return real_->ParseImageInfo(data, size);
}

ArkWebString ArkOhosImageDecoderAdapterImpl::GetEncodedFormat()
{
    return ArkWebStringClassToStruct(real_->GetEncodedFormat());
}

int32_t ArkOhosImageDecoderAdapterImpl::GetImageWidth()
{
    return real_->GetImageWidth();
}

int32_t ArkOhosImageDecoderAdapterImpl::GetImageHeight()
{
    return real_->GetImageHeight();
}

bool ArkOhosImageDecoderAdapterImpl::DecodeToPixelMap(const uint8_t* data, uint32_t size)
{
    return real_->DecodeToPixelMap(data, size);
}

bool ArkOhosImageDecoderAdapterImpl::Decode(const uint8_t* data,
                                            uint32_t size,
                                            uint32_t type,
                                            bool useYuv)
{
    return real_->Decode(data, size, (OHOS::NWeb::AllocatorType)type, useYuv);
}

int32_t ArkOhosImageDecoderAdapterImpl::GetFd()
{
    return real_->GetFd();
}

int32_t ArkOhosImageDecoderAdapterImpl::GetStride()
{
    return real_->GetStride();
}

int32_t ArkOhosImageDecoderAdapterImpl::GetOffset()
{
    return real_->GetOffset();
}

uint64_t ArkOhosImageDecoderAdapterImpl::GetSize()
{
    return real_->GetSize();
}

void* ArkOhosImageDecoderAdapterImpl::GetNativeWindowBuffer()
{
    return real_->GetNativeWindowBuffer();
}

int32_t ArkOhosImageDecoderAdapterImpl::GetPlanesCount()
{
    return real_->GetPlanesCount();
}

void ArkOhosImageDecoderAdapterImpl::ReleasePixelMap()
{
    return real_->ReleasePixelMap();
}

void* ArkOhosImageDecoderAdapterImpl::GetDecodeData()
{
    return real_->GetDecodeData();
}

} // namespace OHOS::ArkWeb
